UNIT – V / 18
DBMS NOTES (R21)
shared-mode lock. Meanwhile, a transaction T3 may request a shared-mode lock on the same
data item. The lock request is compatible with the lock granted to T2, so T3 may be granted the
shared-mode lock. At this point T2 may release the lock, but still T1 has to wait for T3 to finish.
But again, there may be a new transaction T4 that requests a shared-mode lock on the same data
item, and is granted the lock before T3 releases it. In fact, it is possible that there is a sequence of
transactions that each requests a shared-mode lock on the data item, and each transaction releases
the lock a short while after it is granted, but T1 never gets the exclusive-mode lock on the data
item. The transaction T1 may never make progress, and is said to be starved. We can avoid
starvation of transactions by granting locks in the following manner:
When a transaction Ti requests a lock on a data item Q in a particular mode M, the concurrency-
control manager grants the lock provided that
1. There is no other transaction holding a lock on Q in a mode that conflicts with M.
2.There is no other transaction that is waiting for a lock on Q, and that made its lock request
before Ti.
The Two-Phase Locking Protocol
The two-phase locking protocol ensures serializability. This protocol requires that each
transaction issue lock and unlock requests in two phases:
1. Growing phase. A transaction may obtain locks, but may not release any lock.
2. Shrinking phase. A transaction may release locks, but may not obtain any new locks.
Initially, a transaction is in the growing phase. The transaction acquires locks as needed.
Once the transaction releases a lock, it enters the shrinking phase, and it can issue no more lock
requests. Thus, the transaction acquires lock and releases lock as needed. A modification of two-
phase locking is called the Strict Two-Phase Locking Protocols.
Strict Two-Phase Locking Protocol
The Two-Phase Locking Protocol, requires that in addition to locking being two-phase, all
exclusive-mode locks(Exclusive lock is the mode of locking to provide exclusive use of the data
item to only and only transaction) taken by a transaction, must be held until that transaction
commits successfully, preventing any other transaction from reading the data.
Thus, the most widely used locking protocol is the Strict Two-Phase Locking Protocol, also
called as Strict 2PL, has following two rules.